//
//  CustomImageCell.m
//  AnimationRecommend
//
//  Created by ljm on 2017/2/20.
//  Copyright © 2017年 ljm. All rights reserved.
//

#import "CustomImageCell.h"

@implementation CustomImageCell

- (void)setModel:(ManPingModel *)model {
    [_mainImageView sd_setImageWithURL:[NSURL URLWithString:model.pic]];
    _titleLabel.text = model.title;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        _mainImageView = [[UIImageView alloc] initWithFrame:AAdaptionRect(0, 0, kBaseWidth, 400)];
        
        _mainImageView.contentMode = UIViewContentModeScaleAspectFill;
        
        [self.contentView addSubview:_mainImageView];
        
        _titleLabel = [[UILabel alloc] initWithFrame:AAdaptionRect(0, 350, kBaseWidth, 50)];
        
        _titleLabel.backgroundColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.94 alpha:1.f];
        
//        _titleLabel.text = @"一日一漫";
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = [UIFont fontWithName:ManYu_FontStr size:15.f];
        
//        _titleLabel.textAlignment = 1;
        _titleLabel.numberOfLines = 0;
        [self.contentView addSubview:_titleLabel];
    }
    
    return self;
}

/**
 *  返回图片大于imageView的高度
 *
 *  @return 图片大于imageView的高度
 */
- (CGFloat)imageOverflowHeight
{
    // 减200 是因为cell的高度设为200，所以直接写固定值了
    return _mainImageView.frame.size.height - AAdaption(300);
}

/**
 *  设置imageView偏移量
 *
 *  @param imageOffset 偏移量
 */
- (void)setImageOffset:(CGPoint)imageOffset
{
    CGRect frame = _mainImageView.frame;
    frame.origin = imageOffset;
    _mainImageView.frame = frame;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
